<template>
  <div>
    <el-container>
      <el-header class="layout-header">
        <div class="login-user">
          <span class="welcome">欢迎回来,root</span>
          <el-dropdown>
            <el-avatar size="medium" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"></el-avatar>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-plus">修改资料</el-dropdown-item>
              <el-dropdown-item icon="el-icon-circle-plus">修改头像</el-dropdown-item>
              <el-dropdown-item icon="el-icon-circle-plus-outline">修改密码</el-dropdown-item>
              <el-dropdown-item icon="el-icon-check" divided>退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
        <h1>酷鲨商城运营管理平台</h1>
      </el-header>
      <el-container class="layout-body">
        <el-aside class="layout-aside">
          <el-menu
                  :router="true"
                  :default-active="activeMenuItemPath"
                  class="el-menu-vertical-demo"
                  background-color="#222"
                  text-color="#fff"
                  active-text-color="#fff">
            <!-- 首页 -->
            <el-menu-item index="1">
              <i class="el-icon-menu"></i>
              <span slot="title">首页</span>
            </el-menu-item>
            <!-- 商品管理 -->
            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>商品管理</span>
              </template>
              <el-menu-item index="2-1">
                <i class="el-icon-menu"></i>
                <span slot="title">SPU台账</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/product/SPU/insert">
                <i class="el-icon-menu"></i>
                <span slot="title">新增SPU</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/product/album">
                <i class="el-icon-menu"></i>
                <span slot="title">相册管理</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/product/category">
                <i class="el-icon-menu"></i>
                <span slot="title">商品类别</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/product/attributeTemplate">
                <i class="el-icon-menu"></i>
                <span slot="title">属性模板</span>
              </el-menu-item>
              <el-menu-item index="2-6">
                <i class="el-icon-menu"></i>
                <span slot="title">属性管理</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/product/brand">
                <i class="el-icon-menu"></i>
                <span slot="title">品牌管理</span>
              </el-menu-item>
            </el-submenu>
            <!-- 订单管理 -->
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>订单管理</span>
              </template>
              <el-menu-item index="3-1" disabled>
                <i class="el-icon-menu"></i>
                <span slot="title">暂无内容</span>
              </el-menu-item>
            </el-submenu>
            <!--营销管理-->
            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>营销管理</span>
              </template>
              <el-menu-item index="4-1" disabled>
                <i class="el-icon-menu"></i>
                <span slot="title">暂无内容</span>
              </el-menu-item>
            </el-submenu>
            <!--商家管理-->
            <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>商家管理</span>
              </template>
              <el-menu-item index="5-1" disabled>
                <i class="el-icon-menu"></i>
                <span slot="title">暂无内容</span>
              </el-menu-item>
            </el-submenu>
            <!--权限管理-->
            <el-submenu index="6">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>权限管理</span>
              </template>
              <el-menu-item index="/sys-admin/product/admin" >
                <i class="el-icon-menu"></i>
                <span slot="title">管理员管理</span>
              </el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main class="layout-main">
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        activeMenuItemPath:''
      }
    },
    methods: {
      handleActiveMenuItem(){
        let currentPath = this.$router.currentRoute.path;
        if(currentPath.startsWith('/sys-admin/product/album')){
          currentPath='/sys-admin/product/album';
        }
        if(currentPath.startsWith('/sys-admin/permission/admin')){
          currentPath='/sys-admin/permission/admin';
        }
        this.activeMenuItemPath=currentPath;
      }
    },

    mounted() {
       this.handleActiveMenuItem();
    }
  }
</script>

<style>
  .layout-header h1{
    line-height: 60px;
    color: white;
  }
  .layout-header{
    background: dodgerblue;
  }
  .login-user{
    float: right;
    display: flex;
    margin-top: 12px;
  }
  .welcome{
    line-height: 36px;
    color: white;
    margin-right: 10px;
  }
  .layout-body{
    position: absolute;
    top:60px;
    bottom: 0;
    width: 100%;
  }
  .layout-body .layout-aside{
    overflow: hidden;

    background: #222;

  }
  .layout-aside i{
    color: white !important;
  }
  .el-menu-item.is-active{
    background: #3270af !important;
  }
  .layout-main{
    background-color: white;

  }
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    min-height: 100%;
    border: none;
  }
</style>